import 'package:flutter/material.dart';
import 'package:haokezufang/widgets/common_image.dart';

import '../pages/home/tab_search/data_list.dart';
import 'common_tag.dart';

class RoomListItemWidget extends StatelessWidget {
  final RoomListItemData data;

  const RoomListItemWidget({super.key, required this.data});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () {
        Navigator.of(context).pushNamed('/roomdetail/${data.id}');
      },
      child: Container(
        padding: const EdgeInsets.only(
          left: 10.0,
          right: 10.0,
        ),
        child: Row(
          children: [
            CommonImage(src: data.imageUrl, width: 120, height: 90),
            const Padding(padding: EdgeInsets.only(left: 10.0)),
            Expanded(
                child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  data.title,
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                  style: const TextStyle(fontWeight: FontWeight.w600),
                ),
                Text(
                  data.subTitle,
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                ),
                Wrap(
                  children: data.tags
                      .map((e) => CommonTag(
                            title: e,
                          ))
                      .toList(),
                ),
                Text(
                  '${data.price}元/月',
                  style: const TextStyle(
                      color: Colors.orange,
                      fontSize: 16.0,
                      fontWeight: FontWeight.bold),
                ),
              ],
            ))
          ],
        ),
      ),
    );
  }
}
